'''
Created on 2011-04-09

@author: kacper
'''
import os


def getRoot():
    wnCode = 'wnioskowanie_code'
    path =  os.getcwd()
    prefSuf = path.split(wnCode)
    return prefSuf[0] +wnCode


def getAnyDatabase():
    listing = os.listdir(testPath())
    for infile in listing:
        f = testPath()+"/"+infile
        if f.split('.')[-1]=="wn":
            return testPath()+"/"+infile
        
        
def testPath():
    return getRoot()+"/testDataBases"

def savePath():
    return getRoot()+"/savetestDataBases"


def getDirectoryWithTestDatabases():
    return testPath() + "/parseExamples"

def getValidParseExamplesDirs():
    return getDirectoryWithTestDatabases() + "/good/"

def getInvalidParseExamplesDirs():
    return getDirectoryWithTestDatabases() + "/bad/"

def isKnowledgebase(file):
    return file.split('.')[-1]=="wn"
    

def getAllKnowledgeBasesInDir(dir):    
    listing = os.listdir(dir)
    listing = filter(isKnowledgebase, listing)
    listing = map(
        lambda x: dir + x, 
        listing)
    return listing          
    
def getValidParseExamplesList():
    return getAllKnowledgeBasesInDir(getValidParseExamplesDirs());

def getInvalidParseExamplesList():
    return getAllKnowledgeBasesInDir(getInvalidParseExamplesDirs());


